package cn.hp.utils;

import org.apache.shiro.crypto.hash.Md5Hash;

public class MD5Utils {

	public static void main(String[] args) {
		String resource = "123456";//明文密码
		/*//使用md5加密一次
		Md5Hash hash1 = new Md5Hash(resource);
		System.out.println(hash1);
		//使用md5加密两次
		Md5Hash hash2 = new Md5Hash(hash1.toString());
		System.out.println(hash2);
		//使用md5加密一次并加盐
		Md5Hash hash3 = new Md5Hash(resource,"he");
		System.out.println(hash3);*/
		//使用md5加密两次并加盐
		Md5Hash hash4 = new Md5Hash(resource,"wangwu",2);
		System.out.println(hash4);
		/*//调用抽取的方法
		String str = md5("123456", "zhangsan", 2);
		System.out.println(str);*/
	}
	
	public static String md5(Object resource,Object salt,Integer hashIterations) {
		return new Md5Hash(resource, salt, hashIterations).toString();
	}
}
